%data_gen
% clc;
% clear all;
% close all;

% Generating Data 2 gaussian clusters (2*N points with N positivs and N negatives)
% splitting into 2 parts: training will contain 2*Ntrain examples.
N = 500;
Y = [ones(N,1); -ones(N,1)];                                                % label 2N LENGTH
H = [Y/1.5 + randn(2*N,1)/1.5  Y/1.5-randn(2*N,1)/1.5];                         % data
global Hpos Hneg;

%%%%%% data preprocessing for loss_LR
H = [H ones(length(Y),1)];
pos_ind = find(Y == 1);
neg_ind = find(Y == -1);
Hpos = H(pos_ind,:);
Ypos = Y(pos_ind,:);
Hneg = H(neg_ind,:);
Yneg = Y(neg_ind,:);

figure;
plot(Hpos(:,1),Hpos(:,2),'b.'); hold on;
plot(Hneg(:,1),Hneg(:,2),'g.'); hold off;


%%%%%% data preprocessing for loss_LR ends

%For verification: doing logistic regression : Prof. Rudin's plugin.
lambda_GLMFIT = glmfit(H(:,1:2), [0.5*Y(:)+0.5 ones(length(Y(:)),1)], 'binomial', 'link', 'logit');